﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FirstFloor.ModernUI.Windows.Controls;

namespace SimlvClient.Pages
{
    /// <summary>
    /// Interaction logic for UserDetail.xaml
    /// </summary>
    public partial class UserDetail : ModernDialog
    {
        public Model.User UserModel { get; set; }
        public UserDetail(Model.User Model)
        {
            InitializeComponent();
            UserModel = Model;
            GetData(Model);
            Buttons = new[] {
               OkButton, CancelButton
            };
            OkButton.Click += OkButton_Click;
        }

        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserModel == null)
            {
                UserModel = new Model.User();
            }
            UserModel.UserName = this.txtUserName.Text;
            UserModel.Password = this.txtPassword.Password;
            UserModel.Save();
        }

        public void GetData(Model.User Model)
        {
            if (Model != null)
            {
                this.txtUserName.Text = Model.UserName;
                this.txtPassword.Password = Model.Password;
            }
        }

       
    }
}
